package com.桥接模式.factory;

import com.桥接模式.fileService.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 定义稿件服务工厂类：一级工厂类
 */
@Service
public class FileServiceFactory {

    @Autowired
    ChaChongService chaChongService;
    @Autowired
    FanYiService fanYiService;
    @Autowired
    RunSeService runSeService;
    @Autowired
    YuShenService yuShenService;

    private static final ConcurrentHashMap<String, ParentServiceInterface> map=new ConcurrentHashMap<>();

    @PostConstruct
    public void init(){
        map.put(FileServiceEnum.CHA_CHONG.name(),chaChongService);
        map.put(FileServiceEnum.FAN_YI.name(),fanYiService);
        map.put(FileServiceEnum.RUN_SE.name(),runSeService);
        map.put(FileServiceEnum.YU_SHEN.name(),yuShenService);
    }

    public ParentServiceInterface gete(FileServiceEnum fileServiceEnum){
        return map.get(fileServiceEnum.name());
    }
}
